package com.xq.security.token;

import org.springframework.security.authentication.AbstractAuthenticationToken;

/**
 * 手机号验证码登录的自定义token
 */
public class SmsCodeAuthenticationToken extends AbstractAuthenticationToken {
    private final Object principal; // 手机号
    private String code;            // 验证码

    public SmsCodeAuthenticationToken(String phone, String code) {
        super(null);
        this.principal = phone;
        this.code = code;
        setAuthenticated(false); // 未认证
    }

    @Override
    public Object getCredentials() {
        return code;
    }

    @Override
    public Object getPrincipal() {
        return principal;
    }
}